﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;

using System;

namespace SRM.WebSite.Controllers
{
    [AllowAnonymous]
    public class ErrorController : Controller
    {
        public IActionResult Index()
        {
            IExceptionHandlerPathFeature iExceptionHandlerFeature =
                            HttpContext.Features.Get<IExceptionHandlerPathFeature>();

            if (iExceptionHandlerFeature != null)
                return View(iExceptionHandlerFeature);

            return View();
        }

        [HttpGet("/Error/NotFound/{statusCode}")]
        public IActionResult NotFound(int statusCode)
        {
            var iStatusCodeReExecuteFeature = HttpContext.Features.Get<IStatusCodeReExecuteFeature>();
            return View("NotFound", iStatusCodeReExecuteFeature.OriginalPath);
        }
    }
}
